# -*- coding: UTF-8 -*-
'''
@Project ：suanfa 
@File    ：04广度搜索.py
@IDE     ：PyCharm 
@Author  ：Wu
@Date    ：2023/12/20 9:55 
'''

from collections import deque
graph={}
graph["you"]=["alice", "bob", "claire"]
graph["bob"]=["anuj", "peggy"]
graph["alice"]=["peggy"]
graph["claire"]=["thomn", "jonnym"]
graph["anuj"]=[]
graph["peggy"]=[]
graph["thomn"]=[]
graph["jonnym"]=[]
def person_is_seller(name):
    return name[-1] == 'm'


def search(name):
    search_queue=deque()
    for name_ in graph[name]:
        search_queue.append(name_)
    searched=[]
    while search_queue:
        person=search_queue.popleft()
        if person not in searched:
            if person_is_seller(person):
                print(person+" is a mango seller！")
                return True
            else:
                for name__ in graph[person]:
                    search_queue.append(name__)
                searched.append(person)
    print("没有经销商")
    return False

search("you")